include(InstallRequiredSystemLibraries)
include(carbin_print)

set(PROJECT_PACKAGE_DESCRIPTION_SUMMARY ${PROJECT_DESCRIPTION})

SET(CPACK_RESOURCE_FILE_LICENSE "${PROJECT_SOURCE_DIR}/LICENSE")
SET(CPACK_RESOURCE_FILE_README "${PROJECT_SOURCE_DIR}/README.md")
SET(CPACK_PACKAGE_CONTACT ${AUTHOR_MAIL})
SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "${PROJECT_DESCRIPTION}")
SET(CPACK_PACKAGE_DESCRIPTION_FILE "${PROJECT_BINARY_DIR}/package/${PROJECT_NAME}.pc")

set(CPACK_PACKAGING_INSTALL_PREFIX ${PACKAGE_INSTALL_PREFIX})
set(CPACK_PACKAGE_VERSION_MAJOR "${PROJECT_VERSION_MAJOR}")
set(CPACK_PACKAGE_VERSION_MINOR "${PROJECT_VERSION_MINOR}")
set(CPACK_PACKAGE_VERSION_PATCH "${PROJECT_VERSION_PATCH}")
set(CPACK_OUTPUT_FILE_PREFIX ${PROJECT_BINARY_DIR}/package)
set(CPACK_PACKAGE_NAME "${PROJECT_NAME}")

include(carbin_package_generator)

set(CPACK_GENERATOR ${CARBIN_GENERATOR})

carbin_print(${CARBIN_GENERATOR})

if (NOT CMAKE_BUILD_TYPE)
    set(CMAKE_BUILD_TYPE "Debug")
endif ()

string(TOLOWER ${CMAKE_BUILD_TYPE} BUILD_STRING)

set(CPACK_PACKAGE_FILE_NAME
        ${CPACK_PACKAGE_NAME}-${PROJECT_VERSION}-${HOST_SYSTEM_NAME}-${CMAKE_SYSTEM_PROCESSOR}-${BUILD_STRING})
set(CARBIN_PACKAGE_FILE_NAME ${CPACK_PACKAGE_FILE_NAME})
include(CPack)
